<?php
namespace app\admin\model;
use think\model;

class Admin extends Model
{
    protected $name='admin';

    /**
     * 根据搜索条件获取用户列表信息
     * @param $where
     * @param $offset
     * @param $limit
     */
    public function getAdminsByWhere($where, $offset, $limit)
    {
        return $this->where($where)->limit($offset, $limit)->order('id desc')->select();
    }

    /**
     * 根据搜索条件获取所有的用户数量
     * @param $where
     */
    public function getAllAdmins($where)
    {
        return $this->where($where)->count();
    }

    public function checkUser($userName)
    {
        return $this->where('user_name', $userName)
            ->find();
    }
    /**
     * 更新管理员状态
     * @param array $param
     */
    public function updateStatus($param = [], $uid)
    {
        try{
            $this->where('id', $uid)->update($param);
            return ['code'=>1,'msg'=>'ok'];
        }catch (\Exception $e){
            return ['code'=>0,'msg'=>$e->getMessage()];
        }
    }
}